/*
 * GameFace - This is the view; game is the controller.
 *
 * Copyright 2007 James W. Hofmann
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

class GameFace
{

	public static var listening : Bool = false; // listening to Game.cur.phase

	public static function start()
	{
		
		Networker.successfulup = false; // allow us to upload a new score each time we restart the game
		
		if (Main.name==null)
			Main.name = "Guest";
		if (Main.group==null)
			Main.group = "spacecreeps.com"; 

		Title.initgraphics();
		StartGame.initgraphics();
		ComponentManager.add(FortressSprite);
		ComponentManager.add(HUD);
		Gameplay.initgraphics();

				
		Title.setname();
		Title.setsoundtext();
		listening = false;
		Title.screenMain();		
		
	}

	public static function up()
	{	
		if (listening)
			{
			Game.cur.control();
			switch(Game.cur.phase)
			{
				case(-1):
					listening = false;
					Title.screenMain();					
				case(0):
					FortressSprite.refreshall();
					FortressSprite.flatten();
					// show interstitial, send score
				case(1):
					FortressSprite.refreshall();
					FortressSprite.flatten();
					Gameplay.screenPlacement();
					Game.cur.phase = 2;
					Placement.start();
				case(2):
					Placement.up();
				case(3):
					Placement.confirm();
					Gameplay.screenFight();
					FortressSprite.unflatten();
					// fighting begins
				case(4):
					animateboard();
					// during fight				
			}
		}
		else // we're on the title screen
		{
			Title.stars.up();
		}
	}
		
	public static function animateboard()
	{
	}
	
}
